package com.ruoyi.admin.service.impl;

import java.util.ArrayList;
import java.util.List;


import com.ruoyi.admin.vo.MaintainVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.admin.mapper.MaintainMapper;
import com.ruoyi.admin.domain.Maintain;
import com.ruoyi.admin.service.IMaintainService;

/**
 * 维修记录Service业务层处理
 *
 * @author ruoyi
 * @date 2022-10-23
 */
@Service
public class MaintainServiceImpl implements IMaintainService
{
    @Autowired
    private MaintainMapper maintainMapper;


    /**
     * 查询维修记录
     *
     * @param maintainId 维修记录主键
     * @return 维修记录
     */
    @Override
    public Maintain selectMaintainByMaintainId(Long maintainId)
    {
        return maintainMapper.selectMaintainByMaintainId(maintainId);
    }

    /**
     * 查询维修记录列表
     *
     * @param maintain 维修记录
     * @return 维修记录
     */
    @Override
    public List<Maintain> selectMaintainList(Maintain maintain)
    {
        return maintainMapper.selectMaintainList(maintain);
    }

    @Override
    public List<MaintainVo> selectMaintainList2() {
        return maintainMapper.selectMaintainList2();
    }
    /**
     * 查询维修记录列表
     *
     * @param maintain 维修记录
     * @return 维修记录
     */
//    @Override
//    public List<MaintainVo> selectMaintainList2(Maintain maintain)
//    {
//        List<Maintain> maintains = maintainMapper.selectMaintainList(maintain);
//        ArrayList<MaintainVo> list = new ArrayList<>();
//        for (Maintain maintain1 : maintains) {
//            String userName = userMapper.selectUserById(maintain1.getUserId()).getUserName();
//
//            MaintainVo maintainVo = new MaintainVo();
//            maintainVo.setMaintainId(maintain1.getMaintainId());
//            maintainVo.setDescribes(maintain1.getDescribes());
//            maintainVo.setUserId(maintain1.getUserId());
//            maintainVo.setMainStatue(maintain1.getMainStatue());
//            maintainVo.setMainTime(maintain1.getMainTime());
//            maintainVo.setMalfunctionId(maintain1.getMalfunctionId());
//            maintainVo.setUserName(userName);
//            list.add(maintainVo);
//        }
//        return list;
//    }

    /**
     * 新增维修记录
     *
     * @param maintain 维修记录
     * @return 结果
     */
    @Override
    public int insertMaintain(Maintain maintain)
    {
        return maintainMapper.insertMaintain(maintain);
    }

    /**
     * 修改维修记录
     *
     * @param maintain 维修记录
     * @return 结果
     */
    @Override
    public int updateMaintain(Maintain maintain)
    {
        return maintainMapper.updateMaintain(maintain);
    }

    /**
     * 批量删除维修记录
     *
     * @param maintainIds 需要删除的维修记录主键
     * @return 结果
     */
    @Override
    public int deleteMaintainByMaintainIds(Long[] maintainIds)
    {
        return maintainMapper.deleteMaintainByMaintainIds(maintainIds);
    }

    /**
     * 删除维修记录信息
     *
     * @param maintainId 维修记录主键
     * @return 结果
     */
    @Override
    public int deleteMaintainByMaintainId(Long maintainId)
    {
        return maintainMapper.deleteMaintainByMaintainId(maintainId);
    }
}
